#!/bin/bash

# set -ux

#变量

echo '配置java'
mkdir -p /usr/local/java &&
  tar -zxf res/Alibaba_Dragonwell_8.10.11_x64_linux.tar.gz -C /usr/local/java

echo '配置hbase'
tar -zxf res/hbase-2.4.11-bin.tar.gz &&
  mv hbase-2.4.11 /home/hbase &&
  cp -f config/* /home/hbase/conf &&
  mkdir -pv /home/hbase/{tmp,zookeeper}

echo '配置hbase环境'
cat >> /home/hbase/conf/hbase-env.sh << EOF
# java
export JAVA_HOME=/usr/local/java/dragonwell-8.10.11
# hbase
export HBASE_CLASSPATH=/home/hbase/conf
# 不使用自带zookeeper
export HBASE_MANAGES_ZK=false
# 不包含hadoop包
export HBASE_DISABLE_HADOOP_CLASSPATH_LOOKUP="true"
# pid
export HBASE_PID_DIR=/var/hbase/pids
EOF

cat /home/hbase/conf/hbase-env.sh | grep -v '^#' | grep -v '^$'

echo '添加regionservers'
cat > /home/hbase/conf/regionservers << EOF
server163
server164
EOF

echo '添加backup-masters'
cat > /home/hbase/conf/backup-masters << EOF
server164
EOF

cat /home/hbase/conf/regionservers | grep -v '^#' | grep -v '^$'

echo '配置环境变量'
cat >> ~/.bashrc << EOF
# java env
export JAVA_HOME=/usr/local/java/dragonwell-8.10.11
export PATH=\$PATH:\$JAVA_HOME/bin
# hbase env
export HBASE_HOME=/home/hbase
export PATH=\$PATH:\$HBASE_HOME/bin
EOF

cat ~/.bashrc | grep -v '^#' | grep -v '^$'
